package com.bbx.taxi.client.Util;

import java.util.ArrayList;

import org.json.JSONException;
import org.json.JSONObject;

import com.bbx.api.sdk.model.official.passanger.Return.OrderList.OfficialOrderDetail;
import com.bbx.api.sdk.model.official.passanger.Return.OrderList.OfficialOrderList;
import com.bbx.api.sdk.model.official.passanger.Return.OrderList.OfficialOrderList2;
import com.bbx.api.sdk.net.base.JsonBuild;

/**
 * @Path com.bbx.taxi.client.Util.OrderListConvert.java
 * @Author 严旭文
 * @Date 2016-1-27 下午5:24:29
 * @Company 蓝海（福建）信息技术有限公司
 * @Description
 */
public class OrderListConvert {
	/**
     * OfficialOrderList2转换为OfficialOrderList
     */
	public static OfficialOrderList onConvert(OfficialOrderList2 mOfficialOrderList2) {
		OfficialOrderList mOfficialOrderList = null;
		String order_detail = mOfficialOrderList2.getOrderDetail();
		 try {
				JSONObject json = new JSONObject(order_detail);
				order_detail=json.toString();
				mOfficialOrderList2.setOrderDetail(null);
				String JsonString = new JsonBuild().setModel(mOfficialOrderList2).getJsonString();
				
				mOfficialOrderList = (OfficialOrderList) new JsonBuild().getData(OfficialOrderList.class,
						JsonString);
				OfficialOrderDetail mOfficialOrderDetail = (OfficialOrderDetail) new JsonBuild().getData(OfficialOrderDetail.class,
							order_detail);
				mOfficialOrderList.setOrderDetail(mOfficialOrderDetail);
			} catch (JSONException e) {}
		return mOfficialOrderList;

	}
	public static ArrayList<OfficialOrderList> onConvert(ArrayList<OfficialOrderList2> list_orderlist2){
		ArrayList<OfficialOrderList> list=new ArrayList<OfficialOrderList>();
		for(int i=0;i<list_orderlist2.size();i++){
			 String order_detail = list_orderlist2.get(i).getOrderDetail();
			try {
				JSONObject json = new JSONObject(order_detail);
				order_detail=json.toString();
				list_orderlist2.get(i).setOrderDetail(null);
				String JsonString = new JsonBuild().setModel(list_orderlist2.get(i)).getJsonString();
				
				OfficialOrderList mOfficialOrderList = (OfficialOrderList) new JsonBuild().getData(OfficialOrderList.class,
						JsonString);
				OfficialOrderDetail mOfficialOrderDetail = (OfficialOrderDetail) new JsonBuild().getData(OfficialOrderDetail.class,
						order_detail);
				mOfficialOrderList.setOrderDetail(mOfficialOrderDetail);
				list.add(mOfficialOrderList);
			} catch (JSONException e) {
			}
		}
		return list;
		
	}
}
